import React, { Component } from 'react';
import { glData, globalAction, glabalContext } from './globlData.js'
import Child1 from './child1.jsx';
const { Provider } = glabalContext
// Provider(提供者), Consumer(消费者)
class parentContext extends Component {
  state = {
    ...glData,
    ...globalAction(this),
    userInfo:{
      name:'张三',
      age:'18'
    }
  }
  render () {
    return (<>
      <Provider value={this.state}>
        <Child1 />
        <p>父组件读取admin:{this.state.admin}</p>
        <p>父组件本身state：{this.state.userInfo.age}</p>
      </Provider>
    </>);
  }
}

export default parentContext;